package com.joe.socket.Model;

import java.time.LocalDateTime;

public class UserSession {
    private String sessionId;
    private String username;
    private LocalDateTime loginTime;
    private String remoteAddress;
    private boolean isActive;

    public UserSession() {
        this.loginTime = LocalDateTime.now();
        this.isActive = true;
    }

    public UserSession(String sessionId, String username, String remoteAddress) {
        this();
        this.sessionId = sessionId;
        this.username = username;
        this.remoteAddress = remoteAddress;
    }

    // Getter和Setter
    public String getSessionId() { return sessionId; }
    public void setSessionId(String sessionId) { this.sessionId = sessionId; }

    public String getUsername() { return username; }
    public void setUsername(String username) { this.username = username; }

    public LocalDateTime getLoginTime() { return loginTime; }
    public void setLoginTime(LocalDateTime loginTime) { this.loginTime = loginTime; }

    public String getRemoteAddress() { return remoteAddress; }
    public void setRemoteAddress(String remoteAddress) { this.remoteAddress = remoteAddress; }

    public boolean isActive() { return isActive; }
    public void setActive(boolean active) { isActive = active; }

    @Override
    public String toString() {
        return "UserSession{" +
                "sessionId='" + sessionId + '\'' +
                ", username='" + username + '\'' +
                ", loginTime=" + loginTime +
                ", remoteAddress='" + remoteAddress + '\'' +
                ", isActive=" + isActive +
                '}';
    }
}